<?php
class Pageley_Test_Result {
	private $name;
	private $resultType;
	private $exception;
	
	public function __construct($name, $resultType = Pageley_Test_ResultType::SUCCESS, $exception = null) {
		$this->name = $name;
		$this->resultType = $resultType;
		$this->exception = $exception;
	}
	
	public function getFailureCount() {
		return $this->resultType == Pageley_Test_ResultType::FAILURE ? 1 : 0;
	}
	
	public function getErrorCount() {
		return $this->resultType == Pageley_Test_ResultType::ERROR ? 1 : 0;
	}

	public function getSuccessCount() {
		return $this->resultType == Pageley_Test_ResultType::SUCCESS ? 1 : 0;
	}
	
	public function getMethodName() {
		return $this->methodName;
	}
	
	public function getResultType() {
		return $this->resultType;
	}
	
	public function getException() {
		return $this->exception;
	}
	
	public function getName() {
		return $this->name;
	}
	
	public function __toString() {
		return " > Test " . $this->name . ": " . $this->resultType .
			($this->resultType != Pageley_Test_ResultType::SUCCESS ? 
				" (" . $this->exception->getMessage() . ")\n\n" .
				$this->exception . "\n\n" : "\n");
	}
}